package com.nonintrusive.message;

import java.io.Serializable;
import java.util.ArrayList;

public class MessageNonIntrusive implements Serializable {
	private static final long serialVersionUID = 1L;

	public static final int AUTH_TYPE = 0;
	public static final int ASK_QUESTION = 3;
	public static final int ANY_ANSWERS = 4;
	public static final int QUESTION_ID = 5;
	public static final int ANY_QUESTIONS = 6;

	public static final int ANSWER_TYPE = 7;

	// type
	// 0 - client/server set id

	// 2 - client check request
	// 3 - client ask question; sever forwards same message
	// 4 - client answer question
	// 5 - server send summary report for asked questions

	// senderId -1 - sever
	// 0 - client hasn't set an id yet
	// content - actual message to be sent

	public int type = 3;
	public int senderId = -1;
	public String content = "";
	
	public ArrayList<String> answers = new ArrayList<String>();
	public String tags = "";
	public ArrayList<Integer> nrAnswers = new ArrayList<Integer>();

	public int questionId;
	
	public MessageNonIntrusive(int type) {
		this.type = type;
	}

	public MessageNonIntrusive() {
	}

	@Override
	public String toString() {
		return "Message [type=" + type + ", senderId=" + senderId
				+ ", question=" + content + ", answers=" + answers + ", tags="
				+ tags + "]";
	}

	public String nrAnswersToString() {
		StringBuilder sb = new StringBuilder();
		for (Integer nr: nrAnswers) {
			sb.append(nr + " ");
		}
		return sb.toString();
	}

}